﻿@model bdxyit.com.RecruitmentAppSys.Models.UserInfo
@{
    ViewBag.Title = "上传照片";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/ajaxupload.3.6.js")" type="text/javascript"></script>
<script type="text/javascript">
    var vAlertMsg = '图片格式不正确,请选择 jpg|jpeg|gif|png 格式的文件!';
    function createUploader() {
        var upload1 = new AjaxUpload('#btnUpfile', {
            action: '/Handler/uploadPic.ashx', //后台实现上传功能
            responseType: 'json',
            autoSubmit: true,
            onSubmit: function (file, ext) {
                if (!(ext && /^(jpg|jpeg|gif|png)$/ig.test(ext))) {
                    $('#uploading').html('<span>*</span>上传图片类型不正确！');
                    return false;
                }
                $('#uploading').text('<img src="../Content/img/ajax-loader.gif" />文件上传中,请稍后！');
            },
            onComplete: function (file, json) {
                var err = json['Msg'];
                var file1;
                alert(err);
                if (err != null && err != '' && err != "tooBig") {
                    file1 = json['Path'];
                    $('#pic').attr("src", file1);
                    $('#PhotoAddress').val(file1);
                    $('#uploading').css("display", "");
                    $('#uploading').css("color", "red");
                    $('#uploading').text("上传图片成功");
                    $('#finallySubmit').css("display", "");
                }
                else {
                    $('#uploading').css("display", "");
                    $('#uploading').css("color", "red");
                    $('#uploading').text("上传图片失败,照片超过大小限制");
                }
            }
        });
    }
    $(function () {
        createUploader();
    })
</script>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <div id="NavMessage">
        <ul>
            <li>@Html.ActionLink("个人信息", "Index", "EducationInfo")</li>
            <li>@Html.ActionLink("教育信息", "Index", "EducationInfo")</li>
            <li>@Html.ActionLink("工作履历", "Index", "EducationInfo")</li>
            <li>@Html.ActionLink("应聘岗位", "Index", "EducationInfo")</li>
            <li>@Html.ActionLink("上传照片", "Index", "EducationInfo", new { @style = "color: Red;" })</li>
        </ul>
    </div>    
    <div id="BasicMessage">
        <fieldset>
            <legend>上传照片</legend>
               @Html.HiddenFor(model => model.UserID)
            <table>
                <tr>
                    <td colspan="2">
                    <img id="pic"  src="../../Content/img/head.gif"  alt="图片" style="width:100px; height:115px;"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="editor-label">
                            上传照片(图片不能大于120KB)：
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
 @Html.TextBoxFor(model => model.PhotoAddress, new { @style = "width:230px;", @readonly = "readonly" })
 <input type="button" style="width:140px; height:22px; border:0px; background-image:url(/images/img_36.gif);" id="btnUpfile"  value="浏览上传一寸照片"/>
 @Html.ValidationMessageFor(model => model.PhotoAddress)
 <div id="uploading" style=" display:none;"> </div>
                        </div>
                    </td>
                </tr>
            </table>
            <p>
                <input id="finallySubmit" type="submit" value="提交生成用户名与密码"  style=" display:none; "/>
                @Html.ActionLink("上一步", "Edit", "CandidatePositions", new { id = Model.UserID }, new { id = "Up" })
            </p>
        </fieldset>
    </div>
}
